#!/usr/bin/env python
# -*- coding: utf-8 -*-
#===============================================================================
# Copyright 2011 zod.yslin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Author: zod.yslin
# Email: 
# File Name: bytearray.py
# Description: 
#   內建函數 (function) bytearray() ，將參數 (parameter) source 轉換為 bytearray ，
#   若 source 為字串，需提供另一個參數 encoding ，也就是字串的編碼格式
#   bytearray 為內建序列型態之一，可包含多個 0 到 255 的整數， bytearray 為可變的，
#   也就是建立 bytearray 型態的物件後，內容可以更改。
# Edit History: 
#   2011-10-13    File created.
#===============================================================================
d1 = b"12345"
print(type(d1))
d2 = bytearray(d1)
print(type(d2)) 
print(d2)
d2[0] = 54   
print(d2)
d2[1] = 55
print(d2) 
d2[2] = 56
print(d2)
d2[3] = 57
print(d2)
d2[4] = 58
print(d2)
